How to Convert Grayscale to Transparency in Krita

Share
In this tutorial, we'll learn how take a grayscale image, layer, or group layer and make the black color fully transparent and the white fully opaque, or vice-versa, in Krita (version 5.2.9). In other words, we'll convert lightness into alpha. This is useful if you have a black and white image that you want to use as clipping mask, or if you have a line art layer that has white background and you don't want to use the multiply blend mode.
The white text greyscale to transparency against a black background being converted to white on a transparent (symbolized by checkerboard) background.
An example of black being converted to alpha in Krita.

Converting White to Alpha

To convert white to alpha in Krita, follow the following steps:

1: open the image that you want to edit in Krita.

2: select the layer that you want to convert, and add the filter Adjust -> Cross-channel color adjustment to it. In the filter settings, you should see two dropdown list buttons, one for "Channel" and one for "Driver channel," and a curve editor.

3: change "Channel" to "Alpha."

4: change "Driver channel" to "Lightness."

5: move the left control point all the way to the bottom.

Important: the right control point should stay in the center. That's because this filter has a range of "-100%" to "100%." We want zero lightness to result in "-100%" alpha, but we don't need 100% lightness to add another 100% to the alpha. 100% lightness should result in "0%" alpha added or subtracted.

6: click "OK."

This will make every pixel in the layer have its alpha value equal to its lightness. Black pixels will become fully transparent, while white pixels will become fully opaque.

You can now use this as a clipping mask for other layers.

Fixing White Edges after Converting White to Alpha

If you have followed the steps above, you should see that white has been converted to alpha, but there are undesirable white "edges" on your layer.

Three images showing the steps necessary to convert a grayscale checkerboard pattern to a clipping mask: first convert the white to alpha, then set its blend mode to destination in.
An example of how to create a grayscale clipping mask in Krita. Observe that in the middle image, the black squares have grey edges.

This happens because the filter only changes the opacity of the pixels, it hasn't changed their RGB color, which means that any pixel that was grey became 50% transparent and remains still grey. They haven't been converted to white.

To fix this, simply add a Color Overlay layer style to make the whole layer white. If you have a filter layer, the color overlay should be added to the filter layer, so that the color changes AFTER the cross-channel adjustment, not before.

Krita's layer styles dialog, with Color Overlay selected on the left pane. Its options on the main pane are: Blend Mode (Normal), a color button with red selected, and 100% opacity. The dialog has five buttons: Save As..., Import..., Export..., Cancel, and OK.
Krita's Color Overlay layer style effect with the red color selected.

Having finished this, you can save your transparent image to use it elsewhere.

Converting Black to Alpha

To convert black to alpha, the steps are the same as above but instead of making the left side of the cross-channel adjustment filter -100, we make the right side -100, inverting which level of lightness subtracts the alpha.

Video

Gallery

The cross channel color adjustment filter in Krita, turning lightness into alpha; and a white fill layer with inherit alpha.
An old example that configured the filter wrong: both control points are at the corners, which is not how you are supposed to do it.
Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments